/**
 * 
 */
package niuke.xiaohongshu;

import java.util.Scanner;

/**
 * D1RE2345AB D123456RED123456789RT1234511112AB EEEE ERED E00E
 * 
 * @author zhongfang
 *
 */
public class ttt1111 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.nextLine().trim();
		sc.close();
		StringBuilder tmpStr = new StringBuilder();
		String res = "";
		int n = string.length();
		boolean zeroExist = false;
		for (int i = 0; i < n;) {
			char ch = string.charAt(i);
			if (ch <= 'Z' && ch >= 'A') {// 字母
				if (ch == 'R') {
					if (i + 2 < n && string.charAt(i + 1) == 'E' && string.charAt(i + 2) == 'D') {// 忽略RED
						i += 3;
						continue;
					}
				}
				if (tmpStr.length() != 0) {// 比较和现有str的大小
					String tmpS = tmpStr.toString();
					// System.out.println("最大" + res + " 当前" + tmpS);
					if (tmpStr.length() > res.length() || res.compareTo(tmpS) < 0) {// 历史记录小
						// if (isGreater(tmpS, res)) {
						res = tmpS;
					}
					tmpStr = new StringBuilder();// 清空
				}
			} else {// 当前是数字
				if (ch == '0') {
					zeroExist = true;
					if (tmpStr.length() == 0) {// 忽略首0
						i++;
						continue;
					}
				}
				tmpStr.append(ch);
			}
			i++;
		}

		String tmpS = tmpStr.toString();
		if (tmpStr.length() > res.length() || res.compareTo(tmpS) < 0) {// 历史记录小
			res = tmpS;
		}
		if (res.isEmpty()) {
			if (!zeroExist) {
				System.out.println("-1");
			} else {
				System.out.println(0);
			}
		} else {
			System.out.println(res);
		}
	}

	private static boolean isGreater(String tmpS, String res) {
		int i = 0;
		int j = 0;
		while (i < tmpS.length() && tmpS.charAt(i) == '0') {
			i++;
		}

		while (j < res.length() && res.charAt(j) == '0') {

		}
		return false;
	}

}
